<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="index :: common_header(~{::title},~{::link})">
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="../../../css/bootstrap.min.css">
<link rel="stylesheet" href="../../../css/AdminLTE.css">
<link rel="stylesheet" href="../../../css/font-awesome.min.css">
<script type="text/javascript" src="../../../js/jquery.min.js"></script>
</head>
<body class="hold-transition skin-blue sidebar-min">
	<div class="wrapper">
		<header class="main-header" th:replace="~{index :: header}">
			
		</header>

		<aside class="main-sidebar" th:replace="~{index :: common_sodebar}">
		</aside>
		<div class="content-wrapper">
			<div class="content">
				<div class="box box-default">
					<div class="box-header">
						<h3 class="box-title">服务编辑</h3>
					</div>
					<div class="box-body">
						<form data-toggle="ajaxSubmit" action="#" method="post" th:action="@{/manager/save}" th:object="${registeredService}" accept-charset="UTF-8">
							<input type="hidden" th:field="*{id}" >
							<div class="form-group">
								<label th:text="#{common.service_url}">Service URL</label>
								<input type="text" th:field="*{serviceUrl}" class="form-control">
							</div>
							<div class="form-group">
								<label th:text="#{common.name}">Service Name</label>
								<div>
									<input type="text" th:field="*{name}" class="form-control">
								</div>
							</div>
							<div class="form-group">
								<label th:text="#{common.description}">Description</label>
								<div>
									<textarea rows="" cols="" th:field="*{description}" class="form-control"></textarea>
								</div>
							</div>
							<div class="form-group">
								<label>Image URL</label>
								<div>
									<input type="text" class="form-control">
								</div>
							</div>
							<div>
								<button class="btn btn-primary">Save</button>
								<a href="#" th:href="@{/manager/index}" class="btn-default btn">Cal</a>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>

	</div>
	<script type="text/javascript">
		$(document).ready(function(){
			$("form[data-toggle='ajaxSubmit']").submit(function(){
				var parent = $(this).parent();
				while(!parent.hasClass('box-body')){
					parent = parent.parent();
				}
				parent = parent.parent();
				parent.append("<div class='overlay'><i class='fa fa-refresh fa-spin'></i></div>");
				$.ajax({
					url:$(this).attr("action"),
					data:$(this).serialize(),
					type:"POST",
					success:function(result){
						if(result.status == 200){
							window.location.href = result.location
						}else{
							alert(result.message);
						}
					}
				});
				return false;
			});
		});
	</script>
</body>
</html>